﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Chaliy.DbPro.Generators.TextAuthoring.Configuration
{
	[XmlRoot("Text")]
	public class TextConfiguration
	{
		#region Fields

		private ParagraphConfiguration paragraph;
		private SentanceConfiguration sentance;
		private WordConfiguration word;				

		#endregion

		#region Properties

		[XmlElement]
		public ParagraphConfiguration Paragraph
		{
			get
			{
				return this.paragraph;
			}
			set
			{
				this.paragraph = value;
			}
		}

		[XmlElement]
		public SentanceConfiguration Sentance
		{
			get
			{
				return this.sentance;
			}
			set
			{
				this.sentance = value;
			}
		}

		[XmlElement]
		public WordConfiguration Word
		{
			get
			{
				return this.word;
			}
			set
			{
				this.word = value;
			}
		}

		#endregion

		#region Methods

		public static TextConfiguration Load(Stream stream)
		{
			if (stream == null)
			{
				throw new ArgumentNullException("stream");
			}
			
			XmlSerializer serializer = new XmlSerializer(typeof(TextConfiguration));
			return (TextConfiguration)serializer.Deserialize(stream);
		}

		#endregion
	}
}
